import { HttpStatus } from '@nestjs/common';

export class ResultData {
    constructor(
        public code = HttpStatus.OK,
        public message?: string,
        public data?: any,
    ) {
        this.code = code;
        this.message = message || '操作成功';
        this.data = data || null;
    }

    static success(data?: any, message?: string) {
        return new ResultData(HttpStatus.OK, message, data);
    }

    static fail(code = HttpStatus.BAD_REQUEST, message?: string, data?: any) {
        return new ResultData(code, message, data);
    }
}
